//ArrayCompare.java
package com.xyc.ch7;
import java.util.*;

class A1
{
	int i;
	public A1(int a)
	{
		i=a;
	}
}



class B1
{
	int i;
	public B1(int b)
	{
		i=b;
	}
	public boolean equals(Object obj)
	{

		if(obj instanceof B1)
			return ((B1)obj).i==i;
		return false;
	}
}

public class ArrayCompare
{
	public static void main(String[] args)
	{
		int[] a1=new int[10];
		int[] a2=new int[10];
		Arrays.fill(a1,1);
		Arrays.fill(a2,1);
		System.out.println(Arrays.equals(a1,a2));
		a1[0]=2;
		System.out.println(Arrays.equals(a1,a2));

		A1[] a3=new A1[5];
		A1[] a4=new A1[5];
		Arrays.fill(a3,new A1(3));
		Arrays.fill(a4,new A1(3));
		System.out.println(Arrays.equals(a3,a4));

		B1[] a5=new B1[5];
		B1[] a6=new B1[5];
		Arrays.fill(a5,new B1(5));
		Arrays.fill(a6,new B1(5));
		System.out.println(Arrays.equals(a5,a6));
		a5[0].i=6;
		//a6[0].i=6;
		System.out.println(Arrays.equals(a5,a6));

		int[][] a7=new int[2][3];
		Arrays.fill(a7,new int[]{7,7,7});
		int[][] a8=new int[2][3];
		Arrays.fill(a8,new int[]{7,7,7});
		System.out.println(Arrays.equals(a7,a8));
		System.out.println(Arrays.deepEquals(a7,a8));
	}
}

